# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo0922
# Description:
# Author:       yzl
# Date:         2019-03-20
#-------------------------------------------------------------------------------

class Myexception(Exception):
    def __init__(self, *args, **kwargs):  # real signature unknown
        # print(args)
        # for item in args:
        #     print(item)

        self.msg = args[2]

    def __str__(self):
        return self.msg

a = 10

b = 0

if b == 0:
    # return -1 # 没有函数的或类定义的 py 文件,就只能使用主动抛出异常
    # mye = Myexception('系统提示','除数不能为0','下次不要这样了....')
    # print(id(mye))
    print(Myexception('系统提示','除数不能为0','下次不要这样了....'))
    raise Myexception('系统提示','除数不能为0','下次不要这样了....')
else:
    print(a/b)

print('-------------------')

# 主动抛出异常常见的替代方式
def ab_div(a,b):
    if b == 0:
        return '除数不能为0'
    else:
        return a / b

c = ab_div(a,b)
print(c)